

import { readFileSync } from 'fs'
import { join, resolve } from 'path';
let data: string | null = null
export default defineEventHandler(() => {
  try {
    if (!data) {
      // 解析 assets 目录的绝对路径
      const filePath = resolve(join(process.cwd(),'public','lyric','1.lrc'));
      // console.log(filePath)
      // 读取文件内容
      data = readFileSync(filePath,'utf-8');
    }
    return data;
  } catch (error) {
    throw createError({
      statusCode: 500,
      message: 'Failed to read JSON file',
    });
  }
})
